//加载报告
function load_table(url,columns) {
    var table;
    //提示信息
    $.fn.dataTable.ext.errMode = 'none';
    var lang = {
        "bAutoWidth": false,
        "sProcessing": "处理中...",
        "sLengthMenu": "每页 _MENU_ 项",
        "sZeroRecords": "没有匹配结果",
        "sInfo": "当前显示第 _START_ 至 _END_ 项，共 _TOTAL_ 项。",
        "sInfoEmpty": "当前显示第 0 至 0 项，共 0 项",
        "sInfoFiltered": "(由 _MAX_ 项结果过滤)",
        "sInfoPostFix": "",
        "sSearch": "搜索:",
        "sUrl": "",
        "sEmptyTable": "表中数据为空",
        "sLoadingRecords": "载入中...",
        "sInfoThousands": ",",
        "oPaginate": {
            "sFirst": "首页",
            "sPrevious": "上页",
            "sNext": "下页",
            "sLast": "末页",
            "sJump": "跳转"
        },
        "oAria": {
            "sSortAscending": ": 以升序排列此列",
            "sSortDescending": ": 以降序排列此列"
        }
    };
    //初始化表格
    table = $("#dateTable")
        .on("error.dt", function (e, settings, techNote, message) {
            console.warn(message)
        }).dataTable({
            destroy: true,
            autoWidth: false,
            language: lang, //提示信息
            processing: true, //隐藏加载提示,自行处理
            serverSide: false, //启用服务器端分页
            searching: true, //禁用原生搜索
            orderMulti: true, //启用多列排序
            pagingType: "full_numbers", //分页样式：simple,simple_numbers,full,full_numbers
            ajax: function (data, callback, settings) {
                $.ajax({
                    type: "GET",
                    url: url,
                    cache: false, //禁用缓存
                    dataType: "json",
                    success: function (result) {
                        var returnData = {};
                        returnData.data = result;//返回的数据列表
                        // console.log(result);
                        callback(returnData);
                    }
                });
            },
            "columns":columns ,
        }).api();
};

function getStatusName(status,reportId) {
    var temp = "";
    switch (status) {
        case 0:
            temp = "已保存";
            break;
        case 1:
            temp = "待审核";
            break;
        case 2:
            temp = "审核通过";
            break;
        case 3:
            temp = "<a href='javascript:void(0)' onclick='view_reject_msg("+reportId+")' style='color: red'>不合格</a>";
            break;
        case 4:
            temp = "<span style='color:green;'>签发通过</span>";
            break;
        case 5:
            temp = "<a href='javascript:void(0)' onclick='view_reject_msg("+reportId+")' style='color: red'>不合格</a>";
            break;

        case 6:
            temp = "已打印";
            break;
        case 7:
            temp = ">>已归档";
            break;
    }
    return temp;
}

function view_reject_msg(reportId) {
    $("#msg_modal").modal("show");
    $.ajax({
        method:"get",
        url:"/report/getRejectMsg?reportId="+reportId,
        success:function (res) {
            $("#msg").text(res.message);
        }
    });
}